package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Business;
import com.foreknow.elmboot.service.BusinessService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/BusinessController")
public class BusinessController {
    @Autowired
    private BusinessService businessService;

    @RequestMapping("/listBusinessByOrderTypeId")
//    'BusinessController/listBusinessByOrderTypeId'
    public List<Business> listBusinessByOrderTypeId(@RequestParam(required = false) Integer orderTypeId, Model model) {
        List<Business> list = businessService.getBusinessOrderTypeId(orderTypeId);
        return list;
    }

    //    BusinessController/getBusinessById
    @RequestMapping("/getBusinessById")
    public Business getBusinessById(@RequestParam(required = false) Integer businessId, Model model) {
        Business business = businessService.getBusinessById(businessId);
        return business;
    }

}
